var list = BMapSub.SubwayCitiesList;
 var subway;
 $(function() {
 	InitSelect(list); //初始化城市选择框
 	InitMap(131, null);

 });
 //城市选择框改变事件，用于城市地图切换
 $("#_citychoice").change(function() {
 	//var a =  $("#city :selected").text();
 	//console.log(a);
 	InitMap($("#_citychoice").val(), "西单");
 });
 //初始化城市选择框
 function InitSelect(list) {
 	for (var key in list) {
 		var obj = document.getElementById("_citychoice");
 		var option = document.createElement("option"); //创建option节点  
 		option.innerText = list[key].name;
 		option.value = list[key].citycode;
 		obj.appendChild(option);
 	}
 };
 // 获取地铁数据-初始化地铁图
 function InitMap(citycode, startname) {
 	subway = new BMapSub.Subway('container', citycode);
 	subway.setZoom(0.5);
 	var zoomControl = new BMapSub.ZoomControl({
 		anchor: BMAPSUB_ANCHOR_TOP_LEFT,
 		offset: new BMapSub.Size(10, 100)
 	});
 	subway.addControl(zoomControl);
 	//添加站名点击事件
 	subway.addEventListener('tap', function(e) {
 		///alert('您点击了"' + e.station.name + '"站');
 		var marker = new BMapSub.Marker(e.station.name); //, {icon: startIcon}
 		subway.addMarker(marker);
 		subway.setCenter(e.station.name)
 		var a = $("#startname").val();
 		var b = $("#endname").val();
 		if (a == "" || a == "起点") {
 			$("#startname").val(e.station.name);
 		} else {
 			$("#endname").val(e.station.name);
 		}
 		subway.setZoom(0.7);
 	});
 	if (startname != null) {
 		var marker = new BMapSub.Marker(startname); //, {icon: startIcon}
 		subway.addMarker(marker);
 		subway.setCenter(startname);
 		subway.setZoom(0.5);
 	}

 };
